package com.yunhe.rentcars.pro.controller.Client;

import com.yunhe.rentcars.commons.dto.Pageable;
import com.yunhe.rentcars.pro.entity.client.ClientUser;
import com.yunhe.rentcars.pro.entity.client.Credit;
import com.yunhe.rentcars.pro.service.client.ClientUserService;
import com.yunhe.rentcars.pro.service.client.CreditRecordService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * Created by Administrator on 2017/11/29 0029.
 */
@Controller
@RequestMapping("/creditRecord")
public class CreditRecordController {
    @Autowired
    private CreditRecordService creditRecordService;


    @RequestMapping
    public String list(){
        return "/client/creditRecord/list";
    }
    @ResponseBody
    @RequestMapping("/listData")
    public Pageable findPage(Integer offset, Integer limit){
        Pageable<Credit> page = creditRecordService.findPage(offset,limit);
        return page;
    }
    @RequestMapping("/add")
    public String save(String uId, HttpServletRequest request) {
        request.setAttribute("uId",uId);
        return "/client/creditRecord/add";
    }
    @RequestMapping("/save")
    public String save(Credit credit){
        creditRecordService.save(credit);
        return "/client/creditRecord/list";
    }
    @RequestMapping("/searchData")
    @ResponseBody
    public Pageable searchData(String mobile,String idCard){
        Pageable<Credit> pageable = creditRecordService.findSearchList(mobile, idCard);
        return pageable;
    }
}
